package com.ccl.iot.device;

import java.util.ArrayList;

/**
 * @description：安防主机的单个防区
 * @author： HD
 * @time：2017/5/3
 */
public class ArmZoneInfo {

    private byte mReg = 0;

    private int mAddress = 0;

    private ArrayList<String> mTimeData = new ArrayList<String>();
    private ArrayList<Long> mRegLogs = new ArrayList<Long>();

    public ArmZoneInfo(byte data, int address) {
        mReg = data;
        mAddress = address;
    }

    public void setRegDatas(byte newData) {
        mReg = newData;
    }

    public byte getRegDatas() {
        return mReg;
    }


    /**
     * 获取防区类型
     * @return
     */
    public int getType() {
        return (mReg & 0x0f);
    }

    /**
     * 获取线路状态
     * @return
     */
    public int getLineState() {
        return (mReg & 0x10);
    }

    /**
     * 获取防区状态
     * @return
     */
    public int getState() {
        return (mReg & 0xe0);
    }

    public void addTimeData(String time, long refid) {
        mTimeData.add(0, time);
        mRegLogs.add(0, refid);
    }

    public void addTimeDataEnd(String time, long refid) {
        mTimeData.add(time);
        mRegLogs.add(refid);
    }

    public void removeTimeData(int index) {
        mTimeData.remove(index);
        mRegLogs.remove(index);
    }

    public void cleanTimeData() {
        mTimeData.clear();
        mRegLogs.clear();
    }

    public int getTimeDataCount() {
        return mTimeData.size();
    }

    public long getRefId() {
        if (mRegLogs.size() > 0) {
            return mRegLogs.get(0);
        }
        return 0;
    }

    public int getAddress() {
        return mAddress;
    }

    public ArrayList<String> getTimeData() {
        return new ArrayList<String>(mTimeData);
    }


}
